<template>
    <view class="login-container">
        <view class="logo-container">
            <image class="logo" src="/static/images/logo.png" mode="aspectFill" />
        </view>
        <view class="title">商家端登录</view>
        <button class="login-btn" type="primary" @click="handleLogin">微信一键登录</button>
    </view>
</template>

<script setup>
import { useUserStore } from '@/store/user'
import { connect } from '@/utils/websocket'
import { onMounted } from 'vue'


const userStore = useUserStore()


async function handleLogin() {
    try {
        await userStore.login()
        uni.showToast({ title: '登录成功', icon: 'success' })
        // 登录成功后的跳转由store中的checkMerchantEntryStatus方法处理
    } catch (error) {
        console.error('登录失败:', error)
        uni.showToast({ title: '登录失败，请重试', icon: 'none' })
    }
}
</script>

<style lang="scss" scoped>
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: #fff;
}

.logo-container {
    width: 200rpx;
    height: 200rpx;
    border-radius: 50%;
    overflow: hidden;
    margin-top: 80rpx;
    margin-bottom: 30rpx;
}

.logo {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.title {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 40px;
    color: #333;
}

.login-btn {
    width: 80vw;
    max-width: 320px;
    margin-top: 20px;
    font-size: 18px;
    background: linear-gradient(to right, #ff9a9e, #ff6b6b);
    border: none;
    box-shadow: 0 4rpx 12rpx rgba(255, 107, 107, 0.3);
    
    &:active {
        transform: scale(0.95);
    }
}
</style>